<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<%
	String contentPath = request.getContextPath();
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<link rel="stylesheet" href="../../easyui/themes/default/easyui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../easyui/themes/icon.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css"
	media="screen" />
<link rel="stylesheet" type="text/css" href="../../css/Tooltip.css" />
<script src="../../easyui/jquery-1.4.4.min.js"></script>
<script src="../../easyui/jquery.easyui.min.js"></script>
<!-- mytab -->
<script src="../../myjs/myTab.js"></script>
<!-- sys -->
<script src="../../myjs/sys.js"></script>
<script src="../../easyui/easyMask.js"></script>
<script src="../../easyui/easyUI.js"></script>
<script src="../../easyui/easyLayer.js"></script>
<script src="../../myjs/casePropertylend.js"></script>
<script src="../../myjs/util.js"></script>
<script type="text/javascript">
 	var proName = '<%=contentPath%>';
 	var objs = [];  //全局变量,记录条形码
 	var selectRow = []; //临时变量，用来记录分页加载页面时设置选中行
	var greyLayer ;
	$(function(){
		grid = $('#tt').datagrid({
			url:proName+'/casePropertyLend/getStoredGoods',
			height:500,
			pagination:true,
			singleSelect:false,
			// fit:true,//表格自动填充
			loadMsg:'正在努力为您加载，请稍作等待…',//加载信息
			pageSize:10,
			
			onSelect:function(rowIndex, rowData){
				var rows = grid.datagrid('getRows');
				if(objs.length==0){
					objs.push(rowData.t_code);
					setUpSelect(rowIndex,rows,rowData.t_code);
					setDownSelect(rowIndex,rows,rowData.t_code);
				}else{
					if(objs[0] != rowData.t_code){
						sys_alert('错误提示', '一次出库只能选择一个袋中的物品', 'error');
						var selects = $('.datagrid-row-selected');
						for(var i=0;i<selects.length;i++){
							var select = selects.eq(i);
							if(select.attr('datagrid-row-index')==rowIndex){
								select.removeClass('datagrid-row-selected');
							}
						}
					}
						
					/*
					var b = true;
					for(var i=0;i<objs.length;i++){
						if(objs[i] == rowData.t_code){
							b = false;
							break;
						}
					}
					if(b){
						objs.push(rowData.t_code);
						setUpSelect(rowIndex,rows,rowData.t_code);
						setDownSelect(rowIndex,rows,rowData.t_code);
					}
					*/
				}
				
			},
			onUnselect:function(rowIndex, rowData){
				var rows = grid.datagrid('getRows');
				for (var i = 0; i < objs.length; i++) {
			        if (objs[i] == rowData.t_code) {
			        	objs.splice(i, 1);
			        	setUpUnSelect(rowIndex,rows,rowData.t_code);
						setDownUnSelect(rowIndex,rows,rowData.t_code);
			        }
			    }
				
				
			},
			toolbar:[{
				text:'物品调出登记',
				iconCls:'icon-add',
				handler:lend
			},'-',{
				text:'查询',
				iconCls:'icon-function',
				handler:search
				// handler:'func_sys_priv_menu'
			}]
			
		});
		//初始化pagination工具开始
		var pagetool = $('#tt').datagrid('getPager');
		pagetool.pagination({				
				beforePageText:'第',
				afterPageText:'页，共{pages}页',
				displayMsg:'显示从 {from} 到  {to} , 总记录 {total} '});
		//初始化pagination工具结束
					
	
		$('body').layout();
		$('#btn-save,#btn-cancel').linkbutton();


//新增物品
		win_func = $('#win_function').window({
			collapsible:false,
			minimizable:false, 
			maximizable:false, 
			closable:true,
			onClose:function(){greyLayer.close();},
			closed:true,
			cache:false						
		});	
		form_func = win_func.find('form');	
		greyLayer = new easyMask(null,'100%','100%',100,'#000',8,true);
	});
	
</script>
</head>
<body>
<div id="query_condition" region="center" style="overflow:hidden;padding: 1px 1px 1px 1px;">
	<form action="post" >
	<table id='search_table'>
		<tr>
			<td>案件名称：</td>
			<td><input type='text' id='AJMC' name='AJMC'/></td>
			<td>物品名称：</td>
			<td><input type='text' id='WPMC' name='WPMC'/></td>
			<td>办案单位：</td>
			<td><input type='text' id='BADW' name='BADW'/></td>
			<td>办案人：</td>
			<td><input type='text' id='BAR' name='BAR'/></td>
		</tr>
	</table>
	</form>
	<table id="tt">
		<thead>
			<tr>
				<th field="goods_name" width="100%" class="easyui-validatebox">物品名称</th>
				<th field="t_code" width="100%" class="easyui-validatebox">条形码</th>
				<th field="case_name" width="150%" class="easyui-validatebox">案件名称</th>
				<th field="room_name" width="150%" class="easyui-validatebox">物品所在保管室</th>
				<th field="shelf_name" width="150%" class="easyui-validatebox">物品所在保险柜</th>
				<th field="grid_num" width="150%" class="easyui-validatebox">物品所在格子</th>
				<th field="status" width="100%" class="easyui-validatebox">物品状态</th>
				<th field="create_date" width="100%" class="easyui-validatebox">入库日期</th>
				
			</tr>
		</thead>
	</table>
	
	<div id="win_function" iconCls="icon-function" title="涉案物品调出登记"
		style="width: 500px; height: 375px;">
		<form id="form_function" name="form_function" method="post">
		<input type='hidden' name='selectTcode' id='selectTcode'/>
		<!-- left-div -->
		<div >
			<div id="data_div" >
				<input type='hidden' id='gridID' name='gridID'/>
				<table id="data_div_table">
					<tbody>
						<tr>
							<td>调用人员：</td>
							<td><input type='text' id="lend_person" name='lend_person'/></td>	
							
						</tr>
						<tr>
							<td>调用单位：</td>		
							<td><input type='text' id="lend_company" name='lend_company'/></td>	
						</tr>
						<!--
						<tr>
							<td>调用期限：</td>
							<td><input type='text' id="lend_limit" name="lend_limit" />天</td>
						</tr>
						-->
						<tr>
							<td>调出原因：</td>
							<td><textarea name='lend_reason' id='lend_reason' rows='4' cols='40'></textarea></td>
						</tr>
						<tr>
							<td><input type='button' value='调出' onclick='doSave()'/></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</form>
</div>
</div>
</body>
</html>